import React from 'react'
import {connect} from 'react-redux'
import {increment} from '../redux'

// The component, assuming it gets its props from redux
export const Counter = ({count, increment}) =>
  <div>
    <p>Counter value: {count}</p>
    <button onClick={increment}> Increment </button>
  </div>

/* connect() binds redux state and actions to component
 arg1 is a function that takes the full redux store, and returns a map of
   data that get added to the component's props
 arg2 is a map of actions to add to component's props */
export default connect(
  state => ({count: state.count}),
  {increment}
)(Counter)
